/* -*- c++ -*- */
#ifndef __NEW__
#define __NEW__

#include <cstddef>

extern "C++" {

namespace std {
    struct nothrow_t {};
    extern const nothrow_t nothrow;

#ifndef __INTEL_COMPILER
#if (defined(__APPLE__) && __cplusplus < 201103L) || \
    (defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 7)
    // clang and old GCC do not support the definition below, therefore use 
    // this definition which was taken from new header file on Mac
    enum align_val_t { __zero = 0, __max = (size_t)-1 };
#else
    enum class align_val_t : size_t {};
#endif
#endif
}

void* operator new(std::size_t);
void* operator new[](std::size_t);
void  operator delete(void*) throw();
void  operator delete[](void*) throw();
void  operator delete(void*, std::size_t) throw();
void  operator delete[](void*, std::size_t) throw();
void* operator new(std::size_t, const std::nothrow_t&);
void* operator new[](std::size_t, const std::nothrow_t&);
void  operator delete(void*, const std::nothrow_t&) throw();
void  operator delete[](void*, const std::nothrow_t&) throw();

inline void* operator new(std::size_t, void* p) { return p; }
inline void* operator new[](std::size_t, void* p) { return p; }

// these next two are not really required, since exceptions are off
inline void  operator delete(void*, void*) throw() { }
inline void  operator delete[](void*, void*) throw() { }

// for aligned new
void* operator new(std::size_t, std::align_val_t);
void* operator new[](std::size_t, std::align_val_t);
void  operator delete(void*, std::align_val_t) throw();
void  operator delete[](void*, std::align_val_t) throw();
void  operator delete[](void*, std::size_t) throw();

}  // extern C++

#endif // __NEW__
